<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<script type="text/javascript">
	function validateForm(forma){
		var retVal = true;
		var errors = "";
		var periodsNumber = document.getElementById('periods').value;
		var quantity = document.getElementById('quantity').value;
		if( trim(periodsNumber) == "" ){
			errors = errors + '<bean:message key="error.message.blockeddistribution.periods.required"/>\n';
		}
		if( trim(quantity) == "" ){
			errors = errors + '<bean:message key="error.message.blockeddistribution.quantity.required"/>';
		}else{
			if( parseFloat(trim(quantity).replace(/,/g,"")) > parseFloat('<bean:write name="BlockDistributionForm" property="blockDistributionView.purchaseOrderCapacity"/>'.replace(/,/g,"")) ){
				errors = errors + '<bean:message key="error.message.blockeddistribution.quantity"/>';
			}
		}
		if( errors != "" ){
			alert(errors);
			retVal = false;
		}
		return retVal;
	}
</script>
<html:form action="blockDistributionSave">
	<table width="350" align="center" border="0">
		<tr>
			<td colspan="2" class="etiqueta_campo">
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<th colspan="2" align="center" class="titulocolumna"><bean:message key="label.breadcrum.purchaseorder.version.block"/></th>
					</tr>
					<tr>
						<td class="etiqueta" width="50%"><bean:message key="label.purchaseorder.name"/>:</td>
						<td class="etiqueta_campo">
							<bean:write name="BlockDistributionForm" property="blockDistributionView.purchaseOrderCode"/>
						</td>
					</tr>
					<tr>
						<td class="etiqueta" width="50%"><bean:message key="label.purchaseorder.capacity"/>:</td>
						<td class="etiqueta_campo">
							<bean:write name="BlockDistributionForm" property="blockDistributionView.purchaseOrderCapacity"/>
						</td>
					</tr>
					<tr>
						<td class="etiqueta" width="50%"><bean:message key="label.purchaseorder.version.block.blockdate"/>:</td>
						<td class="etiqueta_campo">
							<html:select property="blockDistributionView.startBlockPeriodId" styleClass="columnanumero">
								<html:optionsCollection name="periodosMensuales" label="listDescription" value="monthPeriodId"/>
							</html:select>
						</td>
					</tr>
					<tr>
						<td class="etiqueta" width="50%"><bean:message key="label.purchaseorder.version.block.periodsNumber"/>:</td>
						<td class="etiqueta_campo">
							<html:text styleId="periods" property="blockDistributionView.periodsNumber" maxlength="5" size="1" styleClass="columnanumero" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);"/>
						</td>
					</tr>
					<tr>
						<td class="etiqueta" width="50%"><bean:message key="label.purchaseorder.version.block.quantity"/>:</td>
						<td class="etiqueta_campo">
							<html:text styleId="quantity" property="blockDistributionView.quantity" size="10" styleClass="columnanumero" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,3,false);"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="10">
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<table align="center" width="350" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td style="text-align: center; vertical-align: bottom;" class="columnadatopar">
							<html:submit onclick="return validateForm(this.form);" styleClass="boton"><bean:message key="label.common.save"/></html:submit>
							<html:button property="cancel" onclick="location.href = 'showPurchaseOrderVersionsList.do'" styleClass="boton"><bean:message key="label.common.cancel"/></html:button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</html:form>